package com.imooc.sell.dataobject;

import lombok.Data;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Proxy;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 日统计实体类
 */
@Entity
@Data
@Proxy(lazy = false)
@DynamicUpdate
public class SellByDay extends AbstractStat {
    /**
     * 主键id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer statByDayId;
    /**
     * 昨日销量
     */
    private Integer sellSuccessYes;
    /**
     * 昨日销售额
     */
    private BigDecimal successYesSale;
    /**
     * 昨日取消订单数
     */
    private Integer sellCancelYes;
    /**
     * 昨日退款订单数
     */
    private Integer sellPaybackYes;
    /**
     * 更新时间
     */
    private Date updateTime;

    public SellByDay() {

    }

    public SellByDay(Integer sellSuccessYes, BigDecimal successYesSale, Integer sellCancelYes, Integer sellPaybackYes) {
        this.sellSuccessYes = (Integer) check(sellSuccessYes, Integer.class);
        this.successYesSale = (BigDecimal) check(successYesSale, BigDecimal.class);
        this.sellCancelYes = (Integer) check(sellCancelYes, Integer.class);
        this.sellPaybackYes = (Integer) check(sellPaybackYes, Integer.class);
    }

    public void upToDad() {
        setSellSuccess(getSellSuccessYes());
        setSuccessSale(getSuccessYesSale());
        setSellCancel(getSellCancelYes());
        setSellPayback(getSellPaybackYes());
        setDate(getUpdateTime());
    }


}
